import config from 'config'
import httpFetch from 'share/httpFetch'

export default {
  //获取当前审批节点
  postNowDocumentBrms(params) {
    return httpFetch.post(`${config.baseUrl}/api/approvals/custom/form/brms`,params)
  },

  //获取全部审批列表
  getAdminApproveList( page, size, searchParams) {
    let url = `${config.baseUrl}/api/approvals/admin/batchfilters?page=${page}&size=${size}`;
    for(let searchName in searchParams) {
      if (searchName === 'formOIDs') {
        searchParams.formOIDs && searchParams.formOIDs.length > 0 && searchParams.formOIDs.map(oid => {
          url += `&formOIDs=${oid}`
        })
      }else if(searchName === 'approverOIDs') {
        searchParams.approverOIDs && searchParams.approverOIDs.length > 0 && searchParams.approverOIDs.map(oid => {
          url += `&approverOIDs=${oid}`
        })
      }else if(searchName === 'applicantOIDs') {
        searchParams.applicantOIDs && searchParams.applicantOIDs.length > 0 && searchParams.applicantOIDs.map(oid => {
          url += `&applicantOIDs=${oid}`
        })
      } else {
        url += searchParams[searchName] ? `&${searchName}=${searchParams[searchName]}` : ''
      }
    }
    return httpFetch.get(url)
  },

  //跳转到某个节点
  postSkipDocumentBrms(params) {
    return httpFetch.post(`${config.baseUrl}/api/approvals/admin/skip`,params)
  },

  //审批通过
  handleRequestApprovePass(params) {
    return httpFetch.post(`${config.baseUrl}/api/approvals/admin/pass`, params)
  },

  //审批驳回
  handleRequestApproveReject(params) {
    return httpFetch.post(`${config.baseUrl}/api/approvals/admin/reject`, params)
  },
  //催办
  postPressMessage(params) {
    return httpFetch.post(`${config.baseUrl}/api/approval/remind/urge`,params)
  },

  //获取可转交的数据列表
  getTransferList(params) {
    return httpFetch.get(`${config.baseUrl}/api/approvals/admin/transfer`,params)
  },

  //批量转交
  setAdminTransfer(params) {
    return httpFetch.post(`${config.baseUrl}/api/approvals/admin/transmit`,params)
  },
}
